package cn.iocoder.yudao.module.handguard.controller.app.userbasetable4;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;

import cn.iocoder.yudao.module.handguard.controller.app.userbasetable4.vo.*;
import cn.iocoder.yudao.module.handguard.dal.dataobject.userbasetable4.UserBaseTable4DO;
import cn.iocoder.yudao.module.handguard.convert.userbasetable4.UserBaseTable4Convert;
import cn.iocoder.yudao.module.handguard.service.userbasetable4.UserBaseTable4Service;

@Tag(name = "小程序 - 工薪贷")
@RestController
@RequestMapping("/hutai/user-base-table4")
@Validated
public class UserBaseTable4Controller {

    @Resource
    private UserBaseTable4Service userBaseTable4Service;

    @PostMapping("/create")
    @Operation(summary = "创建工薪贷")
    public CommonResult<Long> createUserBaseTable4(@Valid @RequestBody UserBaseTable4CreateReqVO createReqVO) {
        return success(userBaseTable4Service.createUserBaseTable4(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新工薪贷")
    public CommonResult<Boolean> updateUserBaseTable4(@Valid @RequestBody UserBaseTable4UpdateReqVO updateReqVO) {
        userBaseTable4Service.updateUserBaseTable4(updateReqVO);
        return success(true);
    }


    @GetMapping("/get")
    @Operation(summary = "获得工薪贷")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<UserBaseTable4RespVO> getUserBaseTable4(Long ui) {
        UserBaseTable4DO userBaseTable4 = userBaseTable4Service.getUserBaseTable4(ui);
        return success(UserBaseTable4Convert.INSTANCE.convert(userBaseTable4));
    }

}
